﻿@using rentit03_client.Models
@{
    UserObj user = ViewBag.ViewedUser;
}
<div class="row">
    <div class="span6">
        <table class="table table-striped">
            <tbody>
                @if (user.Id > 0)
                {
                    <tr>
                        <td>
                            <h6>
                                Id:</h6>
                        </td>
                        <td>
                            @user.Id
                        </td>
                    </tr>
                }
                @if (!String.IsNullOrWhiteSpace(user.Email))
                {
                    <tr>
                        <td>
                            <h6>
                                Email:</h6>
                        </td>
                        <td>
                            <a href="mailto:@user.Email">@user.Email</a>
                        </td>
                    </tr>
                }
                @if (!String.IsNullOrWhiteSpace(user.Address))
                {
                    <tr>
                        <td>
                            <h6>
                                Address:</h6>
                        </td>
                        <td>@user.Address
                        </td>
                    </tr>
                }
                @if (!String.IsNullOrWhiteSpace(user.PhoneNumber))
                {
                    <tr>
                        <td>
                            <h6>
                                Phone number:</h6>
                        </td>
                        <td>@user.PhoneNumber
                        </td>
                    </tr>
                }
                @if (!String.IsNullOrWhiteSpace(user.Created))
                {
                    <tr>
                        <td>
                            <h6>
                                Member since:</h6>
                        </td>
                        <td>
                            <time class="timeago" datetime="@user.Created">@user.Created</time>
                        </td>
                    </tr>
                }
                @if (user.Permissions != null && user.Permissions.Contains("ReadUserCredits"))
                {
                    <tr>
                        <td>
                            <h6>
                                Credits:</h6>
                        </td>
                        <td>@user.Credits
                        </td>
                    </tr>
                }
                @if (user.Roles != null && user.Roles.Count > 0 && user.Permissions != null && (user.Permissions.Contains("ReadUserPermissions") || ViewBag.ViewedUser.Id == ViewBag.User.Id))
                {
                    <tr>
                        <td>
                            <h6>
                                Roles:</h6>
                        </td>
                        <td>
                            <ul class="unstyled">
                                @foreach (var p in user.Roles)
                                {
                                    <li>@p</li>
                                }
                            </ul>
                        </td>
                    </tr>
                }
                @if (user.Permissions != null && user.Permissions.Count > 0 && user.Permissions.Contains("ReadUserPermissions"))
                {
                    <tr>
                        <td>
                            <h6>
                                Permissions:</h6>
                        </td>
                        <td>
                            <ul class="unstyled">
                                @foreach (var p in user.Permissions)
                                {
                                    <li>@p</li>
                                }
                            </ul>
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
</div>